home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1992 June: ROMin Holiday / ADC Developer CD (1992-06) (''ROMin Holiday'')_iso / Developer Connection - 06-1992.iso / Periodicals / develop / develop 10 code / GWorld Drawing / GWorld Routines / CBasics.c < prev    next >
Encoding:
C/C++ Source or Header  |  1992-04-08  |  1.7 KB  |  59 lines  |  [TEXT/KAHL]

  1. #include "DemoRoutines.h"
  2.  
  3. long GWGet32PixelC( GWorldPtr src, short x, short y )
  4. {
  5. PixMapHandle    srcPixMap;
  6. unsigned short    srcRowBytes;
  7. long            srcBaseAddr;
  8. long            srcAddr;
  9. char            mmuMode;
  10. long            result;
  11.  
  12.     srcPixMap = GetGWorldPixMap( src );
  13.     srcBaseAddr = (long) GetPixBaseAddr ( srcPixMap );    /* get the address of the pixmap */
  14.     srcRowBytes = (**srcPixMap).rowBytes & 0x7fff;            /* get the row increment */
  15.  
  16. /* Make bounds pixmap relative */
  17.     
  18.     x -= (**srcPixMap).bounds.left;
  19.     y -= (**srcPixMap).bounds.top;
  20.     mmuMode = true32b;
  21.     SwapMMUMode ( &mmuMode );                        /* set the MMU to 32-bit mode */
  22.  
  23. /* Calculate the address of the pixel:  base + y*(row size in bytes) + x*(bytes/pixel) */
  24.  
  25.     srcAddr = srcBaseAddr + (long)y*srcRowBytes + (x<<2);
  26.     result = *(long*)srcAddr;
  27.     SwapMMUMode ( &mmuMode );                        /* restore the previous MMU mode */
  28.     return( result );
  29. }
  30.  
  31. void GWSet32PixelC( GWorldPtr src, short x, short y, long pixelValue )
  32. {
  33. PixMapHandle    srcPixMap;
  34. unsigned short    srcRowBytes;
  35. long            srcBaseAddr;
  36. long            srcAddr;
  37. char            mmuMode;
  38.  
  39.     srcPixMap = GetGWorldPixMap( src );
  40.     srcBaseAddr = (long) GetPixBaseAddr ( srcPixMap );    /* get the address of the pixmap */
  41.     srcRowBytes = (**srcPixMap).rowBytes & 0x7fff;            /* get the row increment */
  42.     
  43. /* Make bounds pixmap relative */
  44.     
  45.     x -= (**srcPixMap).bounds.left;
  46.     y -= (**srcPixMap).bounds.top;
  47.  
  48.     mmuMode = true32b;
  49.     SwapMMUMode ( &mmuMode );                        /* set the MMU to 32-bit mode */
  50.  
  51. /* Calculate the address of the pixel:  base + y*(row size in bytes) + x*(bytes/pixel) */
  52.  
  53.     srcAddr = srcBaseAddr + (long)y*srcRowBytes + (x<<2);
  54. /*    Debugger();    /* mikey */
  55.     *((long *)srcAddr) = pixelValue;
  56.     SwapMMUMode ( &mmuMode );                        /* restore the previous MMU mode */
  57. }
  58.  
  59.